{extend name="base"}
{block name="resources"/}
<style>
	.pagination{
		margin:0;
	}
</style>
{/block}
{block name="body"}
<style>
	.glyphicon-ok{
		color:#3c763d;
		cursor: pointer;
	}
	.glyphicon-remove{
		color:rgb(212, 63, 58);
	}
	.table{
		font-size: 12px;
	}
</style>
<div class="panel panel-info">
	<div class="panel-heading">
		<form class="form-inline pull-left">			 
		  <div class="form-group">
		    <label class="sr-only" for="search">输入要查找的商品名</label>
		    <input type="text" class="form-control" id="exampleInputPassword3" placeholder="输入要查找的商品名">
		  </div>			  
		  <button type="submit" class="btn btn-default">查找</button>
		</form>
		<a href="{:url('goodsAdd')}" class="pull-right btn btn-info">添加商品</a>
		<div class="clear"></div>
	</div>
	<table class="table table-bordered table-hover table-condensed">
		<colgroup>
			<col style="width: 4%;">
			<col style="width: 45%;">
			<col style="width: 5%;">
			<col style="width: 5%;">
			<col style="width: 3%;">
			<col style="width: 8%;">
			<col style="width: 20%;">
		</colgroup>
		<tr>
			<th>
				<div class="checkbox">
					<label>
					  <input type="checkbox" id="checkboxs">ID
					</label>
				</div>
			</th>
			<th>商品名称</th>
			<th>分类</th>
			<th>价格(￥)</th>
			<th>库存</th>
			<th>是否上架</th>
			<th>操作</th>
		</tr>	
		{foreach name="goodsList" item="goodsVal"}
		<tr>
			<td>
				<div class="checkbox">
					<label>
					  <input type="checkbox" class="childcheckboxs">{$goodsVal.id}
					</label>
				</div>
			</td>
			<td>{$goodsVal.name}</td>
			<td>{$goodsVal.cname}</td>
			<td>{$goodsVal.price}</td>
			<td>{$goodsVal.stock}</td>
			<td>{$goodsVal.is_shelf?'<span class="glyphicon glyphicon-ok"></span>':'<span class="glyphicon glyphicon-remove"></span>'}</td>		
			<td>
				<a href=""  class="btn btn-primary btn-sm">查看</a>
				<a href=""  class="btn btn-success btn-sm">修改</a>
				<a href="javascript:"  class="btn btn-danger btn-sm">删除</a>
			</td>
		</tr>
		{/foreach}
	</table>
	<div class="panel-footer">
		<div class="form-horizontal">
		  <div class="form-group">
		    <div class="col-sm-1">
		    	<button type="submit" class="btn btn-default btn-checked" onclick="checkbox(this)">全选</button>
		    </div>
		    <div class="col-sm-2">
		    	<select class="form-control">
		    		<option>选择执行</option>
		    		<option>批量上架</option>
				</select>		      
		    </div>
		    <div class="col-sm-6">
		    	{$goodsList->render()}
		    </div>
		  </div>
		</div>
	</div>

</div>
{/block}
{block name="jsRes"}
<script>
	$('#checkboxs').click(function() {
		$('.childcheckboxs').click();
		/* Act on the event */
		if (this.checked){
			$('.childcheckboxs').attr({
				checked:true
			});			
		}else{
			$('.childcheckboxs').attr({
				checked:false
			});
		}
		console.log(this.checked);
	});
	function checkbox(obj){
		$('.childcheckboxs').click();
		if(obj.innerHTML=='全选'){
			obj.innerHTML="取消";
		}else{
			obj.innerHTML='全选';
		}
	}
</script>
{/block}